<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>temp</title>
    <style>
        body {
            margin: 20px;
            padding: 0px;
            background: #696969;
        }

        .left {
            margin-left: 10%;
            width: 40%;
            height: 600px;
            float: left;
        }

        .right {
            width: 40%;
            height: 600px;
            float: left;
        }

        #inp {
            width: 80%;
            height: 80%;
        }

        #out {
            width: 80%;
            height: 80%;
        }
    </style>
</head>
<body>
<div class="left">
    <textarea id="inp" cols="40" onchange="handler()"></textarea>
</div>
<div class="right">
    <textarea id="out" cols="40"></textarea>
</div>
</body>
<script>
    function handler() {
        var value = document.getElementById('inp').value;
        var list = value.split('\n');
        var re = [];
        for (var tt in list) {
            var td = toList(list[tt]);
            if (td.length == 3) {
                var note = td[0];
                var type = td[1];
                var name = td[2];
                var resultV = "/*" +
                        " \n* " + note +
                        "\n*/" +
                        "\nprivate " + type + " " + name + ";" + "\n\n\n";
                var setMethod = "/*" +
                        " \n* 设置" + note +
                        "\n*/" +
                        "\npublic void set" + toUpperCase(name) + "(" + name + "){" +
                        "\n\tset(" + name + "," + name + ");" +
                        "\n}\n\n\n";
                var getMethod = "/*" +
                        " \n* 取得" + note +
                        "\n*/" +
                        "\npublic " + type + " get" + toUpperCase(name) + "(){" +
                        "\n\treturn get(\"" + name + "\");" +
                        "\n}\n\n\n";

                re.push(resultV+setMethod+getMethod);
                var oldValue = document.getElementById('out').value;
            }
        }
        document.getElementById('out').value = re.join("");
    }

    function toUpperCase(v) {
        var indexOne = v.substring(0, 1);
        var indexLast = v.substring(1);
        var lastValue = indexOne.toUpperCase() + indexLast;
        return lastValue;
    }

    function toList(value){
        console.info(value);
        var resultV = [] ;
        var i = 0 ;
        while(value !=null){
            i++;
            var cn = value.indexOf("：");
            var en = value.indexOf(":");
            console.info('第'+i+'次循环\n中文冒号索引为:'+cn+'\n英文冒号索引为:'+en);
            var indexLast = null ;
            if(cn > en && en != -1){
                resultV.push(value.substring(0,en));
                indexLast = value.substring(en+1);
            }else{
                resultV.push(value.substring(0,cn));
                indexLast = value.substring(cn+1);
            }
            if(indexLast){
                value = indexLast;
            }else{
                value = null;
            }
        }
        console.info(resultV.join(""));
        return resultV.join("");
    }
</script>
</html>